﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace RegistrationManagement.Models
{
    public class Registration 
    {
        public int RegistrationId { get; set; }
        public string HardwardId { get; set; }

        public DateTime IssueDate { get; set; }
        public string IssuedBy { get; set; }


        public int? ContactId { get; set; }
        public Contact ContactInfo { get; set; }

        public int? ContractId { get; set; }
        public Contract Contract { get; set; }
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (ContactId == null && ContractId == null)
            {
                yield return new ValidationResult("ContractId and ContactId can't be both null");
            }
        }
    }

    public class Company
    {
        public int CompanyId { get; set; }
        public string Name { get; set; }
        public List<Registration> Registrations { get; set; }
        public List<Contact> Contacts { get; set; }
    }

    public class Contact
    {
        public int ContactId { get; set; }
        public string Name { get; set; }
        public List<Registration> Registrations { get; set; }

        public int CompanyId { get; set; }
        public Company Company { get; set; }

    }

    public class Contract
    {
        public int ContractId { get; set; }
        public string ContractNo { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }
        public DateTime SignDate { get; set; }
        public int AuthorizeCopiesCount { get; set; }
    }
}